package org.koyabr.webx.demo.danmaku.web.common.util;

import java.util.LinkedList;
import java.util.List;
public class ListTool{
	
	public static <T> List<List<T>> splitList(List<T> originList, int pageLen){
		
		LinkedList<List<T>> pageList = new LinkedList<List<T>>();
		if(originList.isEmpty() || pageLen <= 0){
			return pageList;
		}
		
		int i = 0;
		LinkedList<T> tmpList = new LinkedList<T>();
		for(T obj : originList){
			tmpList.add(obj);
			++i;
			if(i == pageLen){
				pageList.add(tmpList);
				tmpList = new LinkedList<T>();
				i = 0;
			}
			
		}
		
		if(!tmpList.isEmpty()){
			pageList.add(tmpList);
		}
		
		return pageList;
		
	}
	

}